{% set displayVisitorsInOwnColumn = (isWidget ? false : true) %}
{% set displayReferrersInOwnColumn = (clientSideParameters.smallWidth ? false : true) %}
<table class="dataTable" cellspacing="0" width="100%" style="width:100%;table-layout:fixed;">
<thead>
<tr>
    <th style="display:none;"></th>
    <th id="label" class="sortable label" style="cursor: auto;width:190px;" width="190px">
        <div id="thDIV">{{ 'General_Date'|translate }}</div>
    </th>
    {% if displayVisitorsInOwnColumn %}
        <th id="label" class="sortable label" style="cursor: auto;width:225px;" width="225px">
            <div id="thDIV">{{ 'General_Visitors'|translate }}</div>
        </th>
    {% endif %}
    {% if displayReferrersInOwnColumn %}
    <th id="label" class="sortable label" style="cursor: auto;width:230px;" width="230px">
        <div id="thDIV">{{ 'Live_Referrer_URL'|translate }}</div>
    </th>
    {% endif %}
    <th id="label" class="sortable label" style="cursor: auto;">
        <div id="thDIV">{{ 'General_ColumnNbActions'|translate }}</div>
    </th>
</tr>
</thead>
<tbody>
{% set cycleIndex=0 %}
{% for visitor in dataTable.getRows() %}
    {% set breakBeforeVisitorRank = (visitor.getColumn('visitEcommerceStatusIcon') and visitor.getColumn('visitorTypeIcon')) ? true : false %}
    {% set visitorColumnContent %}
        {% if visitor.getColumn('countryFlag') %}<img src="{{ visitor.getColumn('countryFlag') }}" title="{{ visitor.getColumn('location') }}, Provider {{ visitor.getColumn('providerName') }}"/>{% endif %}
        &nbsp;
        {% if visitor.getColumn('plugins') %}
            {% if visitor.getColumn('browserIcon') %}<img src="{{ visitor.getColumn('browserIcon') }}" title="{{ 'UserSettings_BrowserWithPluginsEnabled'|translate(visitor.getColumn('browserName'),visitor.getColumn('plugins')) }}"/>{% endif %}
        {% else %}
            {% if visitor.getColumn('browserIcon') %}<img src="{{ visitor.getColumn('browserIcon') }}" title="{{ 'UserSettings_BrowserWithNoPluginsEnabled'|translate(visitor.getColumn('browserName')) }}"/>{% endif %}
        {% endif %}
        {% if visitor.getColumn('operatingSystemIcon') %}&nbsp;
        <img src="{{ visitor.getColumn('operatingSystemIcon') }}"
             title="{{ visitor.getColumn('operatingSystem') }}, {{ visitor.getColumn('resolution') }} ({{ visitor.getColumn('screenType') }})"/>{% endif %}
        {% if visitor.getColumn('visitorTypeIcon') %}
            {% if visitor.getColumn('visitorTypeIcon') %}&nbsp;-
            <img src="{{ visitor.getColumn('visitorTypeIcon') }}"
                 title="{{ 'General_ReturningVisitor'|translate }} - {{ 'General_NVisits'|translate(visitor.getColumn('visitCount')) }}"/>{% endif %}
        {% endif %}
        {% if not displayVisitorsInOwnColumn or breakBeforeVisitorRank %}<br/><br />{% endif %}
        {% if visitor.getColumn('visitConverted') %}
            <span title="{{ 'General_VisitConvertedNGoals'|translate(visitor.getColumn('goalConversions')) }}" class='visitorRank'
                  {% if not displayVisitorsInOwnColumn or breakBeforeVisitorRank %}style="margin-left:0;"{% endif %}>
            <img src="{{ visitor.getColumn('visitConvertedIcon') }}"/>
            <span class='hash'>#</span>
            {{ visitor.getColumn('goalConversions') }}
            {% if visitor.getColumn('visitEcommerceStatusIcon') %}
                &nbsp;-
                <img src="{{ visitor.getColumn('visitEcommerceStatusIcon') }}" title="{{ visitor.getColumn('visitEcommerceStatus') }}"/>
            {% endif %}
            </span>
        {% endif %}
        {% if not displayVisitorsInOwnColumn %}<br/><br />{% endif %}
        {% if displayVisitorsInOwnColumn %}
            {% if visitor.getColumn('pluginsIcons')|length > 0 %}
                <hr/>
                {{ 'General_Plugins'|translate }}:
                {% for pluginIcon in visitor.getColumn('pluginsIcons') %}
                    <img src="{{ pluginIcon.pluginIcon }}" title="{{ pluginIcon.pluginName|capitalize(true) }}" alt="{{ pluginIcon.pluginName|capitalize(true) }}"/>
                {% endfor %}
            {% endif %}
        {% endif %}
    {% endset %}

    {% set referrerColumnContent %}
    <div class="referrer">
        {% if visitor.getColumn('referrerType') == 'website' %}
            {{ 'Referrers_ColumnWebsite'|translate }}:
            <a href="{{ visitor.getColumn('referrerUrl') }}" rel="noreferrer" target="_blank" title="{{ visitor.getColumn('referrerUrl') }}"
               style="text-decoration:underline;">
                {{ visitor.getColumn('referrerName') }}
            </a>
        {% endif %}
        {% if visitor.getColumn('referrerType') == 'campaign' %}
            {{ 'Referrers_ColumnCampaign'|translate }}
            <br/>
            {{ visitor.getColumn('referrerName') }}
            {% if visitor.getColumn('referrerKeyword') is not empty %} - {{ visitor.getColumn('referrerKeyword') }}{% endif %}
        {% endif %}
        {% if visitor.getColumn('referrerType') == 'search' %}
            {%- set keywordNotDefined = 'General_NotDefined'|translate('General_ColumnKeyword'|translate) -%}
            {%- set showKeyword = visitor.getColumn('referrerKeyword') is not empty and visitor.getColumn('referrerKeyword') != keywordNotDefined -%}
            {% if visitor.getColumn('searchEngineIcon') %}
                <img src="{{ visitor.getColumn('searchEngineIcon') }}" alt="{{ visitor.getColumn('referrerName') }}"/>
            {% endif %}
            <span {% if not showKeyword %}title="{{ keywordNotDefined }}"{% endif %}>{{ visitor.getColumn('referrerName') }}</span>
            {% if showKeyword %}{{ 'Referrers_Keywords'|translate }}:
                <br/>
                <a href="{{ visitor.getColumn('referrerUrl') }}" rel="noreferrer" target="_blank" style="text-decoration:underline;">
                    "{{ visitor.getColumn('referrerKeyword') }}"</a>
            {% endif %}
            {% set keyword %}{{ visitor.getColumn('referrerKeyword') }}{% endset %}
            {% set searchName %}{{ visitor.getColumn('referrerName') }}{% endset %}
            {% set position %}#{{ visitor.getColumn('referrerKeywordPosition') }}{% endset %}
            {% if visitor.getColumn('referrerKeywordPosition') %}
                <span title='{{ 'Live_KeywordRankedOnSearchResultForThisVisitor'|translate(keyword,position,searchName) }}' class='visitorRank'>
                                <span class='hash'>#</span>
                    {{ visitor.getColumn('referrerKeywordPosition') }}
                            </span>
            {% endif %}
        {% endif %}
        {% if visitor.getColumn('referrerType') == 'direct' %}{{ 'Referrers_DirectEntry'|translate }}{% endif %}
    </div>
    {% endset %}

    {% set visitorRow %}
        <tr class="label{{ cycle(['odd','even'], cycleIndex) }}">
        {% set cycleIndex=cycleIndex+1 %}
            <td style="display:none;"></td>
            <td class="label">
                <strong title="{% if visitor.getColumn('visitorType')=='new' %}{{ 'General_NewVisitor'|translate }}{% else %}{{ 'Live_VisitorsLastVisit'|translate(visitor.getColumn('daysSinceLastVisit')) }}{% endif %}">
                    {{ visitor.getColumn('serverDatePrettyFirstAction') }}
                    {% if isWidget %}<br/>{% else %}-{% endif %} {{ visitor.getColumn('serverTimePrettyFirstAction') }}</strong>
                {% if visitor.getColumn('visitIp') is not empty %}
                    <br/>
                <span title="{% if visitor.getColumn('userId') is not empty %}{{ 'General_UserId'|translate }}: {{ visitor.getColumn('userId')|raw }}{% endif %}

{% if visitor.getColumn('visitorId') is not empty %}{{ 'General_VisitorID'|translate }}: {{ visitor.getColumn('visitorId') }}{% endif -%}
{%- if visitor.getColumn('latitude') or visitor.getColumn('longitude') %}

{{ visitor.getColumn('location') }}

GPS (lat/long): {{ visitor.getColumn('latitude') }},{{ visitor.getColumn('longitude') }}{% endif %}">
                    IP: {{ visitor.getColumn('visitIp') }}
                    {% if visitor.getColumn('userId') is not empty %}<br/><br/>{{ visitor.getColumn('userId')|raw }}{% endif %}

                    </span>{% endif %}

                {% if visitor.getColumn('provider') %}
                    <br/>
                    {{ 'Provider_ColumnProvider'|translate }}:
                    <a href="{{ visitor.getColumn('providerUrl') }}" rel="noreferrer" target="_blank" title="{{ visitor.getColumn('providerUrl') }}" style="text-decoration:underline;">
                        {{ visitor.getColumn('providerName') }}
                    </a>
                {% endif %}
                {% if visitor.getColumn('customVariables') %}
                    <br/>
                    {% for id,customVariable in visitor.getColumn('customVariables') %}
                        {% set name='customVariableName' ~ id %}
                        {% set value='customVariableValue' ~ id %}
                        <br/>
                        <acronym title="{{ 'CustomVariables_CustomVariables'|translate }} (index {{ id }})">
                            {{ customVariable[name]|truncate(30) }}
                        </acronym>
                    {% if customVariable[value]|length > 0 %}: {{ customVariable[value]|truncate(50) }}{% endif %}
                    {% endfor %}
                {% endif %}
                {% if not displayVisitorsInOwnColumn %}
                    <br/>
                    {{ visitorColumnContent }}
                {% endif %}
                {% if not displayReferrersInOwnColumn %}
                    <br/>
                    {{ referrerColumnContent }}
                {% endif %}
            </td>

            {% if displayVisitorsInOwnColumn %}
                <td class="label">
                    {{ visitorColumnContent }}
                </td>
            {% endif %}

            {% if displayReferrersInOwnColumn %}
                <td class="column">
                    {{ referrerColumnContent }}
                </td>
            {% endif %}

            <td class="column {% if visitor.getColumn('visitConverted') and not isWidget %}highlightField{% endif %}">
                <div class="visitor-log-page-list">
                    {% if visitor.getColumn('visitorId') is not empty %}
                    <a class="visitor-log-visitor-profile-link" title="{{ 'Live_ViewVisitorProfile'|translate }}" data-visitor-id="{{ visitor.getColumn("visitorId") }}">
                        <img src="plugins/Live/images/visitorProfileLaunch.png"/> <span>{{ 'Live_ViewVisitorProfile'|translate }}
                            {%- if visitor.getColumn('userId') is not empty %}: {{ visitor.getColumn('userId')|raw }}{% endif %}</span>
                    </a>
                    {% endif %}
                    <strong>
                        {{ visitor.getColumn('actionDetails')|length }}
                        {% if visitor.getColumn('actionDetails')|length <= 1 %}
                            {{ 'General_Action'|translate }}
                        {% else %}
                            {{ 'General_Actions'|translate }}
                        {% endif %}
                        {% if visitor.getColumn('visitDuration') > 0 %}- {{ visitor.getColumn('visitDurationPretty')|raw }}{% endif %}
                    </strong>
                    <br/>
                    <ol class='visitorLog'>
                        {% include "@Live/_actionsList.twig" with {'actionDetails': visitor.getColumn('actionDetails')} %}
                    </ol>
                </div>
            </td>
        </tr>
    {% endset %}

    {{ visitorRow }}
{% endfor %}

</tbody>
</table>